package com.zyfdroid.bigdialerkit;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.zyfdroid.bigdialerkit.utils.BaseActivity;

public class DailerActivity extends BaseActivity {
    TextView dialerText;
    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialer);
        dialerText = findViewById(R.id.txtDialerText);
    }

    public void onDialerButtonClick(View view) {
        if(view.getId() == R.id.btnDialerDelete){
            if(dialerText.getText().length() < 1){
                finish();
                return;
            }
            String oldText = dialerText.getText().toString();
            dialerText.setText(oldText.substring(0,oldText.length() - 1));
        }
        else if(view.getId() == R.id.btnDialerCall){
            if(dialerText.getText().length() < 3){

                showToast("电话号码不完整");
                return;
            }
            callPhone(dialerText.getText().toString());

            finish();
        }
        else{
            if(dialerText.getText().length() >= 18){
                return;
            }
            dialerText.setText(dialerText.getText() + ((Button) view).getText().toString());
            makeSound(((Button) view).getText().toString());
        }
    }



    private void makeSound(String which){

    }
}
